using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace Sedna.Core.Controller.Common
{
    public abstract class AbstractRowValidationAction : AbstractGridValidationAction
    {
        public sealed override IActionResult Execute(IExecutionContext executionContext)
        {
            if (TransientData != null && InvalidData != null)
            {
                InvalidData.Clear();
                foreach (Object o in TransientData)
                {
                    if (!ValidateRow(executionContext, o))
                        InvalidData.Add(o);
                }
            }
            SetIsValid(executionContext, InvalidData == null || InvalidData.Count == 0);

            return CreateResult(successStatus);
        }

        protected virtual bool ValidateRow(IExecutionContext executionContext, object value)
        {
            return true;
        }
    }
}
